package com.bins.rabbitmq.consumer;

import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import com.bins.rabbitmq.entity.UserEntity;
import com.rabbitmq.client.Channel;

import lombok.extern.slf4j.Slf4j;

@Component
@Slf4j
public class RabbitmqConsumer {
	
	@RabbitListener(queues = "work_queue")
    public void receiveWorkQueue(String msg, Channel channel, Message message) {
        log.info("接收到消息String：" + msg);
    }

    @RabbitListener(queues = "work_queue")
    public void receiveWorkQueueObject(Object obj, Channel channel, Message message) {
    	log.info("2接收到消息Object：" + obj);
    }
    
    @RabbitListener(queues = "fanout1_queue")
    public void receiveMsg1(String msg) {
    	log.info("fanout1接收到消息：" + msg);
    }

    @RabbitListener(queues = "fanout2_queue")
    public void receiveMsg2(String msg) {
    	log.info("fanout2接收到消息：" + msg);
    }
    
    @RabbitListener(queues = "topic1_queue")
    public void receiveTopic1Msg(String msg) {
    	log.info("消费者1接收到：" + msg);
    }

    @RabbitListener(queues = "topic2_queue")
    public void receiveTopic2Msg(String msg) {
    	log.info("消费者2接收到：" + msg);
    }
    
    @Component
    public class ConfirmReceiveListener {
        @RabbitListener(queues = "confirm_queue")
        public void receiveMsg(UserEntity user) {
        	log.info("接收到的消息为：" + user);
        }
    }
    
    @RabbitListener(queues = "return_queue")
    public void receiveMsg(String msg) {
    	log.info("接收的消息为：" + msg);
    }

}
